package vn.mahjonggame.util;

import java.io.*;
import java.util.*;

public class Property {
		
	private String propFile = null;
	
	public Property(String propFile){
		this.setPropFile(propFile);
	}
	
	public HashMap<String,String> readProperties() {		        
        Properties prop = new Properties();
        InputStream input = null;
        HashMap<String,String> propMap = new HashMap<String,String>();
        
    	try {     
    		input = new FileInputStream(this.getPropFile());    		
    		prop.load(input);    		    	
    		
    		for(Iterator<Object> keys = prop.keySet().iterator(); keys.hasNext();){
    			String key = (String)keys.next();
    			propMap.put(key, prop.getProperty(key, null));
    		}
      
    	} catch (Throwable t) {
    		//logger.error("Failed in Property: readProperties", t);
    	} finally {
    		if (input != null) {
    			try {
    				input.close();
    			} catch (Throwable t) {}
    		}
    	}
        
        return propMap;
    }

	public String getPropFile() {
		return propFile;
	}

	public void setPropFile(String propFile) {
		this.propFile = propFile;
	}
}
